package com.fh.alipay.model.convert;


import lombok.experimental.UtilityClass;
import com.fh.alipay.po.Order;
import com.fh.alipay.model.dto.OrderDTO;
import com.fh.alipay.model.vo.OrderVO;
import java.util.ArrayList;
import java.util.List;

/**
 * @author fh
 * @date 2022-05-04
 * @description 订单表转换类
 */

@UtilityClass
public class OrderConvert {


    public static Order toPO(OrderDTO dto){
        Order result = new Order();
            result.setId(dto.getId());
            result.setCreateTime(dto.getCreateTime());
            result.setUpdateTime(dto.getUpdateTime());
            result.setChargeFinishTime(dto.getChargeFinishTime());
            result.setProductId(dto.getProductId());
            result.setProductName(dto.getProductName());
            result.setCustomerOrderNo(dto.getCustomerOrderNo());
            result.setOrderStatus(dto.getOrderStatus());
            result.setChargeAccount(dto.getChargeAccount());
            result.setAccountType(dto.getAccountType());
            result.setBuyNum(dto.getBuyNum());
            result.setChargeGameName(dto.getChargeGameName());
            result.setChargeGameRegion(dto.getChargeGameRegion());
            result.setChargeGameSrv(dto.getChargeGameSrv());
            result.setChargeType(dto.getChargeType());
            result.setChargePassword(dto.getChargePassword());
            result.setChargeIp(dto.getChargeIp());
            result.setContactQq(dto.getContactQq());
            result.setContactTel(dto.getContactTel());
            result.setRemainingNumber(dto.getRemainingNumber());
            result.setChargeGameRole(dto.getChargeGameRole());
            result.setCustomerPrice(dto.getCustomerPrice());
            result.setShopType(dto.getShopType());
            result.setOrderId(dto.getOrderId());
        return result;
    }

    public static OrderVO toVO(Order po){
        OrderVO result = new OrderVO();
                result.setId(po.getId());
                result.setCreateTime(po.getCreateTime());
                result.setUpdateTime(po.getUpdateTime());
                result.setChargeFinishTime(po.getChargeFinishTime());
                result.setProductId(po.getProductId());
                result.setProductName(po.getProductName());
                result.setCustomerOrderNo(po.getCustomerOrderNo());
                result.setOrderStatus(po.getOrderStatus());
                result.setChargeAccount(po.getChargeAccount());
                result.setAccountType(po.getAccountType());
                result.setBuyNum(po.getBuyNum());
                result.setChargeGameName(po.getChargeGameName());
                result.setChargeGameRegion(po.getChargeGameRegion());
                result.setChargeGameSrv(po.getChargeGameSrv());
                result.setChargeType(po.getChargeType());
                result.setChargePassword(po.getChargePassword());
                result.setChargeIp(po.getChargeIp());
                result.setContactQq(po.getContactQq());
                result.setContactTel(po.getContactTel());
                result.setRemainingNumber(po.getRemainingNumber());
                result.setChargeGameRole(po.getChargeGameRole());
                result.setCustomerPrice(po.getCustomerPrice());
                result.setShopType(po.getShopType());
                result.setOrderId(po.getOrderId());
            return result;
    }
    public static List<OrderVO> toVO(List<Order> pos){
        if(pos == null){
            return null;
        }
        List<OrderVO> list = new ArrayList<>();
        for(Order po:pos){
            list.add(toVO(po));
        }
        return list;
    }

    public static List<Order> toPO(List<OrderDTO> dtos){
        if(dtos == null) {
            return null;
        }
        List<Order> list = new ArrayList<>();
        for(OrderDTO dto:dtos) {
            list.add(toPO(dto));
        }
        return list;
    }


}
